package com.zzvcom;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

public class HdfsClient {
    public static void main(String[] args) throws URISyntaxException, IOException, InterruptedException {
        testCopy();
    }

    private static void testCopy() throws IOException, InterruptedException, URISyntaxException {
        Configuration conf = new Configuration();
        conf.set("dfs.replication", "2");
        FileSystem fs = FileSystem.get(new URI("hdfs://hadoop1:9000"), conf, "root");
        fs.copyFromLocalFile(new Path("D:/hello.txt"), new Path("/"));
        fs.close();
    }
}
